﻿(function(){
Gis_Window = {
    document : null,
	x_open_path : '/JS/round/',
    symbol_img : "/JS/round/symbol.gif",
    close_img : "/JS/round/close.gif",
    title_img : "/JS/round/title.gif",
    bottom_img :  "/JS/round/bottom.gif",
    intern_img : "/JS/round/intern.gif",
    grip_img : "/JS/round/grip.gif",
    border_img : "/JS/round/border.gif",
    loading_page : "/JS/round/loading.htm",
    initialwidth : -1, 
    initialheight : -1,
    x_open_ie5 : null,
    x_open_ns6 : null,
    x_open_win_id : null,
    title_msg_layer_id : null,
    x_open_frame_id : null,
    border_img_name1_id :  null,
    border_img_name2_id :  null,
    x_open_win_border_id :  null,
    win_frame : null,
    openScreenDivObj : new Object(),
    Open:function(title,url,width,height) {
        if(this.win_frame == null )
            this.initWinDiv();
        if (!this.x_open_ie5 && !this.x_open_ns6)
		    window.open(url, "", "width=width,height=height,scrollbars=1");
	    else{
		    this.initialwidth = width ? width:document.body.clientWidth;
		    this.initialheight = height ? height:"600";
		    this.change_size(this.initialwidth, this.initialheight);
		    this.x_open_win_id.style.left = "0px";
		    this.x_open_win_id.style.top=this.x_open_ns6 ? window.pageYOffset * 1 + 0 + "px" : this.iecompattest().scrollTop * 1 + 0 + "px";
//		    this.x_open_frame_id.src = url;
		    this.x_open_frame_id.innerHTML = "<iframe src='" + url + "' frameborder=0 noresize style='width:100%; height:100%;background-color: #ffffff;color: #333;margin: 0px; padding: 0px;border:0px '></iframe>\r\n";
		    this.title_msg_layer_id.innerHTML = '<font color=#333333>' + title + '</font>';
		    this.x_open_win_id.style.display = 'block';
	    }
    },
    destroyopenScreenDivObj : function(){
//        if(this.openScreenDivObj.parentNode)
//            this.openScreenDivObj.parentNode.removeChild(this.openScreenDivObj);
//        this.openScreenDivObj = null;
        this.x_open_win_id.style.display = 'none';
    },
    iecompattest:function(){
	    return (!window.opera && this.document.compatMode && this.document.compatMode!="BackCompat")? this.document.documentElement : this.document.body
    },
    closeit:function (){
	    this.destroyopenScreenDivObj();
	    return true;
    },
    change_size:function(w, h){ 
		if(w > 150 ) {
			this.x_open_win_id.style.width = w + "px";
		}else{
			this.x_open_win_id.style.width = 150 +"px";
		}
		if(h > 0 ) {
			this.x_open_win_id.style.height = this.border_img_name1_id.style.height = this.border_img_name2_id.style.height = this.x_open_frame_id.style.height = h + "px";
		}else{
			this.x_open_win_id.style.height = this.border_img_name1_id.style.height = this.border_img_name2_id.style.height = this.x_open_frame_id.style.height = 0 + "px";
			
		}
    },
    remove_units:function (elem){
	    return(parseInt(elem.replace(/px/g,"")));			
    },
    initWinDiv:function() {
        this.document =  window.document;
        var cDiv = this.document.createElement("div");
        cDiv.id = "x_open_win";
        var styleStr = 'position:absolute;z-index:100000; width: 420px; height: 350px ;left:10px;top:10px;font-size:12px; display:none ';
        cDiv.style.cssText = styleStr;
        if( this.win_frame == null ) {
            this.win_frame = "";
            this.win_frame += "<div>\r\n";
            this.win_frame += "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>\r\n";
            this.win_frame += "	<tr>\r\n";
            this.win_frame += "		<td style='width:19px;height:21px;background: url(" + this.symbol_img + "); padding:0px'></td>\r\n";
            this.win_frame += "		<td width='5' style='background: url(" + this.title_img + "); padding:0px'></td><td style='background: url(" + this.title_img + "); padding:0px'><font color='#333333'><div id='title_msg_layer'><strong>title</strong></div></font>\r\n";
            this.win_frame += "		</td>\r\n";
            this.win_frame += "		<td style='background: url(" + this.title_img + "); padding:0px'></td>\r\n";
            this.win_frame += "	<td  style='cursor:pointer;width:16px;text-align:center '>";
            this.win_frame += "<img src='" + this.close_img + "' onclick='Gis_Window.closeit()' width='16' height='21' border='0' title='关闭窗口' />";
            this.win_frame += "</td>\r\n";
            this.win_frame += "	</tr>\r\n";
            this.win_frame += "</table>\r\n";
            this.win_frame += "</div>\r\n";
            this.win_frame += "<div id='x_open_content' align=center style='width:100%;  margin: 0px;background-color: #ffffff;	MOZ-OPACITY:0.50;FILTER :  Alpha(opacity=100);'>\r\n";
            this.win_frame += "<table style='width:100%; height:100%; margin: 0px;' border='0' cellpadding='0' cellspacing='0'>\r\n";
            this.win_frame += "	<tr>\r\n";
            this.win_frame += "		<td width='1'><img src='" + this.border_img + "' id='border_img_name1' border='0' style='border:0px; width:1px; height:317px; margin: 0px;' /></td>\r\n";
            this.win_frame += "		<td>\r\n";
              this.win_frame += "		<div id='x_open_frame' name='x_open_frame' style='width:100%; height:100%;'></div>";
//            this.win_frame += "		<iframe id='x_open_frame' name='x_open_frame' src='" + this.loading_page + "' frameborder=0 noresize style='width:100%; height:100%;background-color: #ffffff;color: #333;margin: 0px; padding: 0px;border:0px '></iframe>\r\n";
            this.win_frame += "		</td>\r\n";
            this.win_frame += "		<td width='1'><img src='" + this.border_img + "' id='border_img_name2' border='0' style='border:0px; width:1px; height:317px; margin: 0px;' /></td>\r\n";
            this.win_frame += "	</tr>\r\n";
            this.win_frame += "</table>\r\n";
            this.win_frame += "</div>\r\n";
            this.win_frame += "<div align='center' style='width:100%;height:15px;background: url(" + this.bottom_img + ");' onselectstart='return false'>\r\n";
            this.win_frame += "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>\r\n";
            this.win_frame += "	<tr>\r\n";
            this.win_frame += "		<td width='28'><img src='" + this.intern_img + "' width='28' height='15' border='0' /></td>\r\n";
            this.win_frame += "			<td width='42'></td>\r\n";
            this.win_frame += "		<td><div id='size_info_layer'>&nbsp;</div></td>\r\n";
            this.win_frame += "		<td>&nbsp;</td>\r\n";
            this.win_frame += "		<td width='19'><img src='" + this.grip_img + "' border='0' style='width:19px;height:15px;'/></td>\r\n";
            this.win_frame += "	</tr>\r\n";
            this.win_frame += "</table>\r\n";
            this.win_frame += "</div>\r\n";
        }
        cDiv.innerHTML = this.win_frame;
//        this.openScreenDivObj = cDiv;
        this.document.body.appendChild(cDiv);
        cDiv = null;
        this.x_open_ie5 = this.document.all && this.document.getElementById;
        this.x_open_ns6 = this.document.getElementById && !this.document.all;
        this.x_open_win_id = this.document.getElementById("x_open_win");
        this.title_msg_layer_id = this.document.getElementById("title_msg_layer");
        this.x_open_frame_id = this.document.getElementById("x_open_frame");
        this.border_img_name1_id = this.document.getElementById("border_img_name1");
        this.border_img_name2_id = this.document.getElementById("border_img_name2");
        this.x_open_win_border_id = this.document.getElementById("x_open_win_border");
    }
}
})()
